<?php

require_once(sfConfig::get('sf_lib_dir').'/filter/base/BaseFormFilterPropel.class.php');

/**
 * Level filter form base class.
 *
 * @package    elearning
 * @subpackage filter
 * @author     Your name here
 */
class BaseLevelFormFilter extends BaseFormFilterPropel
{
  public function setup()
  {
    $this->setWidgets(array(
      'course_id'               => new sfWidgetFormPropelChoice(array('model' => 'Course', 'add_empty' => true)),
      'level_price'             => new sfWidgetFormFilterInput(),
      'level_status'            => new sfWidgetFormFilterInput(),
      'teach_sessions_per_week' => new sfWidgetFormFilterInput(),
      'prac_sessions_per_week'  => new sfWidgetFormFilterInput(),
      'total_sessions'          => new sfWidgetFormFilterInput(),
      'duration_in_week'        => new sfWidgetFormFilterInput(),
      'create_at'               => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'update_at'               => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
    ));

    $this->setValidators(array(
      'course_id'               => new sfValidatorPropelChoice(array('required' => false, 'model' => 'Course', 'column' => 'id')),
      'level_price'             => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'level_status'            => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'teach_sessions_per_week' => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'prac_sessions_per_week'  => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'total_sessions'          => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'duration_in_week'        => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'create_at'               => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
      'update_at'               => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
    ));

    $this->widgetSchema->setNameFormat('level_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function getModelName()
  {
    return 'Level';
  }

  public function getFields()
  {
    return array(
      'id'                      => 'Number',
      'course_id'               => 'ForeignKey',
      'level_price'             => 'Number',
      'level_status'            => 'Number',
      'teach_sessions_per_week' => 'Number',
      'prac_sessions_per_week'  => 'Number',
      'total_sessions'          => 'Number',
      'duration_in_week'        => 'Number',
      'create_at'               => 'Date',
      'update_at'               => 'Date',
    );
  }
}
